<template>
  <div>
    <el-form-item label="数据源">
      <el-button @click="open">配置</el-button>
    </el-form-item>
    <line-chart-setting v-model="visible" :data="localData.options" @update="handleOptionsUpdate" />
  </div>
</template>

<script>
import lineChartSetting from './lineChartSetting.vue';
export default {
  name: 'LineChartConfig',
  components: {
    lineChartSetting
  },
  props: {
    data: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      visible: false,
      localData: {}
    };
  },
  watch: {
    data: {
      handler(newVal) {
        if (newVal) {
          this.localData = newVal;
        }
      },
      deep: true,
      immediate: true
    },
    localData: {
      handler(newVal) {
        this.$emit('update:data', newVal);
      },
      deep: true
    }
  },
  methods: {
    open(){
        this.visible = true;
    },
    handleOptionsUpdate(data){
        this.localData.options = data;
    }
  }
};
</script>

<style></style>
